﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter5.Section3
{
    public class Example01
    {
        public Example01()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            V.Function.ToLastType<double[], double> f
                = new V.Function.ToLastType<double[], double>(func);
            double[] from = { 0.0, 0.0 };
            double[] to = { Math.PI / 2.0, Math.PI / 2.0 };
            V.IntegrationMultiD obj = new V.IntegrationMultiD(f, from, to);
            obj.Compute();
            result += obj.BestEstimation.ToString() + "\r\n";
            obj.NumberOfCall = 10000000;
            obj.Compute();
            result += obj.BestEstimation.ToString() + "\r\n";
            double com = Math.Pow(Math.PI, 6.0) / 768.0 + Math.PI / 2.0 - 1.0;
            result += com.ToString() + "\r\n";
        }
        private double func(double[] x)
        {
            if (x[1] > x[0]) return 0.0;
            else return x[1] * x[0] * x[0] * x[0] + Math.Cos(x[0]);
        }
    }
}
/* 
1.82238322209926
1.82260774132923
1.82260517259607
*/